package com.xiaofeng.pochi.controller;

import com.xiaofeng.pochi.common.Page;
import com.xiaofeng.pochi.common.Result;
import com.xiaofeng.pochi.pojo.ShopCoupon;
import com.xiaofeng.pochi.pojo.ShopOrderPay;
import com.xiaofeng.pochi.service.ShopOrderPayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created with IntelliJ IDEA
 *
 * @Author: chc
 * @Date: 2022/09/25/21:43
 * @Description:
 */
@RestController
@RequestMapping("/orderPay")
public class ShopOrderPayController {

    @Autowired
    private ShopOrderPayService shopOrderPayService;


    /**
     * 分页查询
     * @param page
     * @return
     */
    @RequestMapping(value = "/getByPage", method = RequestMethod.POST)
    public Result<Page<ShopOrderPay>> getByPage(@RequestBody Page<ShopOrderPay> page)  {
        page = shopOrderPayService.getByPage(page);
        return new Result<>(page);
    }

    /**
     * 查询详情
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/get/{id}", method = RequestMethod.GET)
    public Result<ShopOrderPay> get(@PathVariable Long id) {
        ShopOrderPay pay = shopOrderPayService.get(id);
        return new Result<>(pay);
    }

    /**
     * 根据商品订单id查询
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/getByOrderId/{id}", method = RequestMethod.GET)
    public Result<ShopOrderPay> getByOrderId(@PathVariable Long id) {
        ShopOrderPay pay = shopOrderPayService.getByOrderId(id);
        return new Result<>(pay);
    }

}
